{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Simple Attack\n",
    "\n",
    "In this notebook, we will examine perhaps the simplest possible attack on an individual's private data and what the OpenDP library can do to mitigate it.\n",
    "\n",
    "## Loading the data\n",
    "\n",
    "The vetting process is currently underway for the code in the OpenDP Library.\n",
    "Any constructors that have not been vetted may still be accessed if you opt-in to \"contrib\"."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 78,
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "from opendp.mod import enable_features\n",
    "enable_features('contrib')"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "We begin with loading up the data."
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "execution_count": 79,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['age', 'sex', 'educ', 'race', 'income', 'married']\n",
      "59,1,9,1,0,1\n",
      "31,0,1,3,17000,0\n",
      "36,1,11,1,0,1\n",
      "54,1,11,1,9100,1\n",
      "39,0,5,3,37000,0\n",
      "34,0,9,1,0,1\n"
     ]
    }
   ],
   "source": [
    "import os\n",
    "data_path = os.path.join('.', 'data', 'PUMS_california_demographics_1000', 'data.csv')\n",
    "\n",
    "with open(data_path) as input_file:\n",
    "    data = input_file.read()\n",
    "\n",
    "col_names = [\"age\", \"sex\", \"educ\", \"race\", \"income\", \"married\"]\n",
    "print(col_names)\n",
    "print('\\n'.join(data.split('\\n')[:6]))"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "The following code parses the data into a vector of incomes.\n",
    "More details on preprocessing can be found [here](https://github.com/opendp/opendp/blob/main/python/example/basic_data_analysis.ipynb)."
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "execution_count": 80,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[0.0, 17000.0, 0.0, 9100.0, 37000.0, 0.0, 6000.0]\n"
     ]
    }
   ],
   "source": [
    "from opendp.trans import make_split_dataframe, make_select_column, make_cast, make_impute_constant\n",
    "\n",
    "income_preprocessor = (\n",
    "    # Convert data into a dataframe where columns are of type Vec<str>\n",
    "    make_split_dataframe(separator=\",\", col_names=col_names) >>\n",
    "    # Selects a column of df, Vec<str>\n",
    "    make_select_column(key=\"income\", TOA=str)\n",
    ")\n",
    "\n",
    "# make a transformation that casts from a vector of strings to a vector of floats\n",
    "cast_str_float = (\n",
    "    # Cast Vec<str> to Vec<Option<floats>>\n",
    "    make_cast(TIA=str, TOA=float) >>\n",
    "    # Replace any elements that failed to parse with 0., emitting a Vec<float>\n",
    "    make_impute_constant(0.)\n",
    ")\n",
    "\n",
    "# replace the previous preprocessor: extend it with the caster\n",
    "income_preprocessor = income_preprocessor >> cast_str_float\n",
    "incomes = income_preprocessor(data)\n",
    "\n",
    "print(incomes[:7])"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "## A simple attack\n",
    "\n",
    "Say there's an attacker who's target is the income of the first person in our data (i.e. the first income in the csv). In our case, its simply `0` (but any number is fine, i.e. 5000)."
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "execution_count": 81,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "person of interest:\n",
      "\n",
      "0.0\n"
     ]
    }
   ],
   "source": [
    "person_of_interest = incomes[0]\n",
    "print('person of interest:\\n\\n{0}'.format(person_of_interest))"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "Now consider the case an attacker that doesn't know the POI income, but do know the following: (1) the average income without the POI income, and (2) the number of persons in the database.\n",
    "As we show next, if he would also get the average income (including the POI's one), by simple manipulation he can easily back out the individual's income."
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "execution_count": 82,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "poi_income: 0.0\n"
     ]
    }
   ],
   "source": [
    "# attacker information: everyone's else mean, and their count.\n",
    "known_mean = np.mean(incomes[1:])\n",
    "known_obs = len(incomes) - 1\n",
    "\n",
    "# assume the attackers know legitimately get the overall mean (and hence can infer the total count)\n",
    "overall_mean = np.mean(incomes)\n",
    "n_obs = len(incomes)\n",
    "\n",
    "# back out POI's income\n",
    "poi_income = overall_mean * n_obs - known_obs * known_mean\n",
    "print('poi_income: {0}'.format(poi_income))"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "The attacker now knows with certainty that the POI has an income of $0.\n",
    "\n",
    "\n",
    "## Using OpenDP\n",
    "Let's see what happens if the attacker were made to interact with the data through OpenDP and was given a privacy budget of $\\epsilon = 1$.\n",
    "We will assume that the attacker is reasonably familiar with differential privacy and believes that they should use tighter data bounds than they would anticipate being in the data in order to get a less noisy estimate.\n",
    "They will need to update their `known_mean` accordingly."
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "execution_count": 83,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "DP mean: 28203.570278867388\n",
      "Known mean: 28488.08080808081\n"
     ]
    }
   ],
   "source": [
    "from opendp.trans import make_clamp, make_sized_bounded_mean, make_bounded_resize\n",
    "from opendp.meas import make_base_laplace\n",
    "\n",
    "enable_features(\"floating-point\")\n",
    "\n",
    "max_influence = 1\n",
    "count_release = 100\n",
    "\n",
    "income_bounds = (0.0, 100_000.0)\n",
    "\n",
    "clamp_and_resize_data = (\n",
    "    make_clamp(bounds=income_bounds) >>\n",
    "    make_bounded_resize(size=count_release, bounds=income_bounds, constant=10_000.0)\n",
    ")\n",
    "\n",
    "known_mean = np.mean(clamp_and_resize_data(incomes)[1:])\n",
    "\n",
    "mean_measurement = (\n",
    "    clamp_and_resize_data >>\n",
    "    make_sized_bounded_mean(size=count_release, bounds=income_bounds) >>\n",
    "    make_base_laplace(scale=1.0)\n",
    ")\n",
    "\n",
    "dp_mean = mean_measurement(incomes)\n",
    "\n",
    "print(\"DP mean:\", dp_mean)\n",
    "print(\"Known mean:\", known_mean)"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "We will be using `n_sims` to simulate the process a number of times to get a sense for various possible outcomes for the attacker.\n",
    "In practice, they would see the result of only one simulation."
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%% md\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 84,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Known Mean Income (after truncation): 28488.08080808081\n",
      "Observed Mean Income: 28203.193459994138\n",
      "Estimated POI Income: -0.6540005867157132\n",
      "True POI Income: 0.0\n"
     ]
    }
   ],
   "source": [
    "# initialize vector to store estimated overall means\n",
    "n_sims = 10_000\n",
    "n_queries = 1\n",
    "poi_income_ests = []\n",
    "estimated_means = []\n",
    "\n",
    "# get estimates of overall means\n",
    "for i in range(n_sims):\n",
    "    query_means = [mean_measurement(incomes) for j in range(n_queries)]\n",
    "\n",
    "    # get estimates of POI income\n",
    "    estimated_means.append(np.mean(query_means))\n",
    "    poi_income_ests.append(estimated_means[i] * count_release - (count_release - 1) * known_mean)\n",
    "\n",
    "\n",
    "# get mean of estimates\n",
    "print('Known Mean Income (after truncation): {0}'.format(known_mean))\n",
    "print('Observed Mean Income: {0}'.format(np.mean(estimated_means)))\n",
    "print('Estimated POI Income: {0}'.format(np.mean(poi_income_ests)))\n",
    "print('True POI Income: {0}'.format(person_of_interest))"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "We see empirically that, in expectation, the attacker can get a reasonably good estimate of POI's income. However, they will rarely (if ever) get it exactly and would have no way of knowing if they did.\n",
    "\n",
    "In our case, indeed the mean estimated POI income approaches the true income, as the number of simulations `n_sims` increases.\n",
    "Below is a plot showing the empirical distribution of estimates of POI income. Notice about its concentration around `0`, and the Laplacian curve of the graph."
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "execution_count": 85,
   "outputs": [
    {
     "data": {
      "text/plain": "[Text(0.5, 0, 'Estimated POI income')]"
     },
     "execution_count": 85,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "text/plain": "<Figure size 432x288 with 1 Axes>",
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYQAAAEGCAYAAABlxeIAAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/MnkTPAAAACXBIWXMAAAsTAAALEwEAmpwYAAAbNElEQVR4nO3df5BV9Znn8fdnZNREDaB0kAAOJEEzJlVR7FVr8qNMSBDdRGTHODiTBJRZNkYzMc4kYqyK2WSdSJKJo5UsWSIsuuWIriMjmzJD8FeY2RWhQVBQ0fZXhAJp/IGOTlD02T/O0/HSfZvu+7Mv8HlV3epzn/O99zz33O779Pl+z/0eRQRmZmZ/MNgJmJlZa3BBMDMzwAXBzMySC4KZmQEuCGZmloYMdgJ7M2LEiBg3btxgp2Fmtk9Zs2bNjohoq/RxLV0Qxo0bR0dHx2CnYWa2T5H0bDWPc5eRmZkBLghmZpZcEMzMDHBBMDOz5IJgZmaAC4KZmSUXBDMzA1wQzMwsuSCYmRnQ4t9UNmsF8xYsYtuOnb3iR48YyoWzZjY/IbMGcUEw68e2HTs57rRpveKb7lsyCNmYNY67jMzMDHBBMDOz5IJgZmaAC4KZmSUXBDMzA1wQzMwsuSCYmRnggmBmZqnfgiBpoaTtkjb0iH9N0mOSNk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+GfgWuAOSYdS/Jd6aa5bDPxC0l/xznTmlbgJ+D/ZLdIBPAYQES/kgOoG4FcR8c08O+j+/Cz8N+CLEbFW0i0Us3Rup+h7H7CIWCppNPD/JAVFIfpi1Gcq568D8yXNojhyuDAi7pe0iHemYb4+Ih5UcSW1gfg+8PfAQ5L+AHia4hoVdgDybKdmZga4y8jMzJILgpmZAS4IZmaWXBDMzAxwQTAzs+SCYGZmgAuCmZml/w+tkuCffWOUuQAAAABJRU5ErkJggg==\n"
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "import warnings\n",
    "import seaborn as sns\n",
    "\n",
    "# hide warning created by outstanding scipy.stats issue\n",
    "warnings.simplefilter(action='ignore', category=FutureWarning)\n",
    "\n",
    "# distribution of POI income\n",
    "ax = sns.distplot(poi_income_ests, kde = False, hist_kws = dict(edgecolor = 'black', linewidth = 1))\n",
    "ax.set(xlabel = 'Estimated POI income')"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 85,
   "outputs": [],
   "source": [],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%"
    }
   }
  }
 ],
 "metadata": {
  "file_extension": ".py",
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.2"
  },
  "mimetype": "text/x-python",
  "name": "python",
  "npconvert_exporter": "python",
  "pygments_lexer": "ipython3",
  "version": 3
 },
 "nbformat": 4,
 "nbformat_minor": 2
}